package md.mru.frontend.utils;

import java.util.EnumSet;

/**
 * @author sergiu.marin
 * @since 18.05.2014.
 */
public enum _OrderStateType {
    NEW("Nou"),
    TRAINEE("Training"),
    VALIDATED("Validat"),
    EMPLOYED("Angajat"),
    TRANSFER("Transfer"),
    DEPLASARE("Deplasare"),
    HOLIDAY("In concediu"),
    MATERNITY_LEAVE("Concediu de maternitate"),
    MEDICAL_LEAVE("Concediu medical"),
    RETURN_TO_WORK("Reluarea activitatii"),
    TEMPORARILY_SUSPENDED("Suspendat temporar"),
    FIRED("Concediat");

    private final String label;

    static {
        initialize();
    }

    _OrderStateType(String label) {
        this.label = label;
    }

    public _OrderStateType[] availableFolderStates;

    private static void initialize() {
        NEW.availableFolderStates = new _OrderStateType[] {TRAINEE, EMPLOYED};
        TRAINEE.availableFolderStates = new _OrderStateType[] {EMPLOYED, TEMPORARILY_SUSPENDED, FIRED};
        VALIDATED.availableFolderStates = new _OrderStateType[] {EMPLOYED};
        EMPLOYED.availableFolderStates = new _OrderStateType[] {HOLIDAY, TRANSFER, MATERNITY_LEAVE, MEDICAL_LEAVE, TEMPORARILY_SUSPENDED, FIRED};
        HOLIDAY.availableFolderStates = new _OrderStateType[] {RETURN_TO_WORK, MATERNITY_LEAVE, MEDICAL_LEAVE, TEMPORARILY_SUSPENDED, FIRED};
        MATERNITY_LEAVE.availableFolderStates = new _OrderStateType[] {RETURN_TO_WORK, MEDICAL_LEAVE, TEMPORARILY_SUSPENDED, FIRED};
        MEDICAL_LEAVE.availableFolderStates = new _OrderStateType[] {RETURN_TO_WORK, HOLIDAY, MATERNITY_LEAVE, TEMPORARILY_SUSPENDED, FIRED};
        TEMPORARILY_SUSPENDED.availableFolderStates = new _OrderStateType[] {RETURN_TO_WORK, FIRED};
        FIRED.availableFolderStates = new _OrderStateType[] {NEW};
    }

    public static EnumSet<_OrderStateType> NOT_GENERAL_STATES = EnumSet.of(HOLIDAY, MATERNITY_LEAVE, MEDICAL_LEAVE, TEMPORARILY_SUSPENDED);

    public String getLabel() {
        return label;
    }
}
